import axios from 'axios'
import config from '../config'

export function create (entity) {
  return axios.post(config.SERVER_URL + window.apiPath + '/sos-ships', {...entity, responseType: 'json'})
    .then(resp => resp.data)
}

export function update (entity) {
  return axios.put(config.SERVER_URL + window.apiPath + '/sos-ships', {...entity, responseType: 'json'})
    .then(resp => resp.data)
}

export function deleteById (id) {
  return axios.delete(config.SERVER_URL + window.apiPath + '/sos-ships/' + id, {responseType: 'json'})
    .then(resp => resp.data)
}

export function search (page, query = '', size = config.PAGE_SIZE) { //
  return axios.get(config.SERVER_URL + window.apiPath + `/sos-ships-ps?page=${page}&size=${size}&query=${query}`, {responseType: 'json'})
  // return axios.get(config.SERVER_URL + window.apiPath + `/sos-ships`, {params: params}, {responseType: 'json'})
    .then(resp => resp)
}

export function searchAll (query = '') { //
  return axios.get(config.SERVER_URL + window.apiPath + `/sos-ships?query=${query}`, {responseType: 'json'})
  // return axios.get(config.SERVER_URL + window.apiPath + `/sos-ships`, {params: params}, {responseType: 'json'})
    .then(resp => resp)
}

export function searchById (id) {
  return axios.get(config.SERVER_URL + window.apiPath + '/sos-ships/' + id, {responseType: 'json'})
    .then(resp => resp.data)
}
